package com.optimatch.ui.view.customComponents.pages;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.MutableComboBoxModel;

import com.optimatch.model.solver.Solution;

public class ResultatParEquipePanel extends JPanel {

	private JComboBox choixEquipe;
	private JPanel resultat;
	private JTable table;
	private Object[][] data;
	private JScrollPane scroll;

	public ResultatParEquipePanel() {
		super();
		init();
	}

	private void init() {
		this.setLayout(new BorderLayout());
		choixEquipe = new JComboBox();
		resultat = new JPanel(new GridLayout(1,1));
		scroll = new JScrollPane();
		resultat.add(scroll);
		this.add(choixEquipe, BorderLayout.NORTH);
		this.add(resultat, BorderLayout.CENTER);
	}

	public void setListeEquipes(){
		MutableComboBoxModel boxModelEquipe = new DefaultComboBoxModel();
		for (int i=0;i<Solution.getNombreEquipes();i++) {
			boxModelEquipe.addElement(Solution.getListeEquipes().get(i).getName());
		}
		choixEquipe.setModel(boxModelEquipe);
	}
	public Object[][] getData() {
		return data;
	}
	public void setData(Object[][] data) {
		resultat.remove(scroll);
		table = new JTable(data,new String[]{"Journee","Equipe adversaire","Domicile  Exterieur"});
		table.setRowHeight(30);
		table.setBackground(new Color(217,226,243));
		scroll = new JScrollPane(table);
		resultat.add(scroll);
		this.data = data;
		repaint();
	}
	public JComboBox getChoixEquipe() {
		return choixEquipe;
	}

	public void setChoixEquipe(JComboBox choixEquipe) {
		this.choixEquipe = choixEquipe;
	}
}
